package com.java.comprehensive.design.building_modelling.factory_pattern.coffee.example;

class CoffeeStore {
    public Coffee orderCoffee(String coffeeType) {
        Coffee coffee = null;
        if ("美式".equals(coffeeType)) {
            coffee = new AmericaCoffee();
        } else if ("拿铁".equals(coffeeType)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException();
        }
        addCoffeeAttr(coffee);
        return coffee;
    }

    private void addCoffeeAttr(Coffee coffee) {
        coffee.addSugar();
        coffee.addMilk();
    }

}
